function is_email(email) {
    var reg = /^([A-Za-z0-9_\-\.])+\@([A-Za-z0-9_\-\.])+\.([A-Za-z]{2,4})$/;
    return reg.test(email);
}
function set_client_cookie(c_name, value, exdays) {
    var exdate = new Date();
    exdate.setDate(exdate.getDate() + exdays);
    var c_value = escape(value) + ((exdays == null) ? "" : "; expires=" + exdate.toUTCString());
    document.cookie = c_name + "=" + c_value;
}
function get_client_cookie(c_name) {
    var i, x, y, ARRcookies = document.cookie.split(";");
    for (i = 0; i < ARRcookies.length; i++) {
        x = ARRcookies[i].substr(0, ARRcookies[i].indexOf("="));
        y = ARRcookies[i].substr(ARRcookies[i].indexOf("=") + 1);
        x = x.replace(/^\s+|\s+$/g, "");
        if (x == c_name) {
            return unescape(y);
        }
    }
}
function number_format(Num) {
    if (Num == undefined)
        Num = 0;

    Num = Num.toString().replace(/^0+/, "").replace(/\./g, "").replace(/,/g, "");// Bỏ hết số 0 ở đầu dãy số | Bỏ hết dấu . trong dãy số
    Num = "" + parseInt(Num);
    var temp1 = "";
    var temp2 = "";

    if (Num == 0 || Num == undefined || Num == '0' || Num == '' || isNaN(Num)) {
        return 0;
    }
    else {
        //if (end.length == 2) end += "0";
        //if (end.length == 1) end += "00";
        //if (end == "") end += ",00";
        var count = 0;
        for (var k = Num.length - 1; k >= 0; k--) {
            var oneChar = Num.charAt(k);
            if (count == 3) {
                temp1 += ".";
                temp1 += oneChar;
                count = 1;
                continue;
            }
            else {
                temp1 += oneChar;
                count++;
            }
        }

        for (var k = temp1.length - 1; k >= 0; k--) {
            var oneChar = temp1.charAt(k);
            temp2 += oneChar;
        }
        //temp2 = temp2 + end;
        return temp2;
    }
}

function currency_to_number(value) {
    return Number(value.replace(/[$.]+/g, ""));
}
